package com.lhnstart.learn.bases.innerclass;

/**
 * 内部类实践
 *
 * @author lhn
 * @date 2023/07/18 14:47
 * @since 1.0.0
 **/
public class AnonymousInnerClassDetail {

    public static void main(String[] args) {
        Outer05 outer05 = new Outer05();
        outer05.f1();
    }

}

class Outer05 {
    private int n1 = 99;

    public void f1() {
        Person person = new Person() {
            @Override
            public void hi() {
                System.out.println("匿名内部类重写了 h1 方法" + n1);
                super.hi();
            }
        };
        person.hi();

        new Person() {
            @Override
            public void hi() {
                System.out.println("匿名内部类重写了 h1 方法,回去回去...");
            }
        }.hi();

    }
}

class Person {
    public void hi() {
        System.out.println("person h1");
    }
}

